<%@ page import="rwt.server.util.JspUtil.SwitchStateData,java.util.*" %>

<!DOCTYPE html>
<html>
<head>
<title>Simple Switch</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<script src="websock.js"></script>
	<script src="/jquery/jquery-1.8.2.min.js"></script>
	<script src="/jquery/jquery.ui.core.js"></script>
	
	<script>
		function handleMessage(obj)
		{
			var state = "";
			switch(obj.state)
			{
			case SWITCH_BEGIN_THROWN:
			case SWITCH_BEGIN_CLOSED:
				state = "changing";
				break;
			case SWITCH_CLOSED:
				state = "closed";
				break;
			case SWITCH_THROWN:
				state = "thrown";
				break;
			case SWITCH_UNKNOWN:
			default:
				state = "unknown";
				break;
			}
			$('#switch' + obj.switchId).attr("state", state);
		}
		
		
		switches = new Switches(handleMessage);
	</script>
</head>
<body class="dialog">
<div class="visual_switches" >
	<%
		List<SwitchStateData> switchStateList = (List<SwitchStateData>) request.getAttribute("rwt.switchStateData"); 
		for (SwitchStateData switchState : switchStateList)
		{
	%>
	<div id="switch<%=switchState.switchId%>" style="left: <%=switchState.layoutX%>px; top: <%=switchState.layoutY%>px;" state="unknown" onclick="switches.changeSwitch(<%=switchState.switchId%>)"><%=switchState.switchId%></div>
	<% } %>
</div>
</body>
</html>